/**
 * Created by asus on 2017/10/16.
 */
public class PascalTriangle {
    public static void main(String[] args) {
            PascalTriangle myPascal = new PascalTriangle();
            myPascal.Circular(5);
    }
    public void Circular(int n){
        CircularArrayQueue myCircular = new CircularArrayQueue(n+2);
        myCircular.enqueue(0);
        myCircular.enqueue(1);
        myCircular.enqueue(0);
        System.out.print(1+" "+"\n");
        for (int i=1;i<=n;i++){
            for (int j=1;j<=i+1;j++){
                    int first = (int)myCircular.dequeue();
                    int second = (int)myCircular.first();
                    int num = first+second;
                    myCircular.enqueue(num);
                    System.out.print(num+" ");
            }
            myCircular.enqueue(0);
            System.out.print("\n");
        }
    }

}
